//我关注的企业
import React, {Component} from 'react';
import {
    View,
    Text,
    Image,
    TouchableOpacity,
} from 'react-native';
import {followStyle as styles} from '../../../../styles';
import fmt from '../../../util/fmtDateUtil';
import Nature from '../../../util/Nature';
import {common_url} from "../../../util/fetch";

var Dimensions = require('Dimensions');
var width = Dimensions.get('window').width;
var height = Dimensions.get('window').height;

export default class GuanzhuLv extends Component {
    constructor(props) {
        super(props);
    }

    render() {
        return (
            <TouchableOpacity style={styles.fol_allin}
                              onPress={() => {
                                  this.goGet('Company', this.props.company.companyId)
                              }}
                              activeOpacity={1}>
                <View style={styles.fol_topa}>
                    <Image source={
                        this.props.company.companyPicture ?
                            {uri: common_url + "uploadImg/" + this.props.company.companyPicture}
                            : require('../../../img/app/company.png')} style={styles.fol_head}/>
                    <View style={[styles.fol_tr, {width: width * 0.7}]}>
                        <View style={styles.fol_in1}>
                            <Text style={styles.fol_bpos}>{this.props.company.companyName}</Text>
                        </View>
                        <View style={styles.fol_in2}>
                            <Text style={styles.fol_pla1}>{this.props.company.companyCity}</Text>
                            {this.fieldName(this.props.company.domains, 2)}
                        </View>
                        <View style={styles.fol_in4}>
                            <Text style={styles.fol_can}>{fmt(this.props.companys.followTime, "yyyy-MM-dd")}</Text>
                        </View>
                        <View style={styles.fol_in5}>
                            <Text style={styles.fol_com}>{Nature(this.props.company.companyNature)}</Text>
                        </View>
                    </View>
                </View>

                <View style={[styles.fol_botb, {width: width * 0.9}]}>
                    <View style={styles.fol_in6}>
                        <Text style={styles.fol_hot}>热门职位 :</Text>
                    </View>

                    <View style={styles.fol_in7}>
                        {this.postionName(this.props.company.postions, 2)}
                    </View>

                </View>
            </TouchableOpacity>
        )
    }

    //经营领域
    fieldName(List, sl) {
        var data = {
            cont: List
        }
        var arr = [];
        var s = sl;
        var length = data.cont.length;
        if (length <= s) {
            s = length;
        }
        for (var i = 0; i < s; i++) {
            arr.push(
                <Text key={i} style={styles.fol_pla}>{data.cont[i].field.fieldName}</Text>
            )
        }
        return arr;
    }

    //热门职位
    postionName(List, sl) {
        var data = {
            cont: List
        }
        var arr = [];
        var s = sl;
        var length = data.cont.length
        if (length <= s) {
            s = length
        }
        for (var i = 0; i < s; i++) {
            arr.push(
                <Text key={i} style={styles.fol_hotin}>{data.cont[i].postionName}</Text>
            )
        }
        return arr;
    }

    //待遇
    welfareName(List, sl) {
        var data = {
            cont: List
        }
        var arr = [];
        var s = sl;
        var length = data.cont.length
        if (length <= s) {
            s = length
        }
        for (var i = 0; i < s; i++) {
            arr.push(
                <Text key={i} style={styles.fol_mat}>{data.cont[i].welfareName}</Text>
            )
        }
        return arr;
    }

    goGet(name, id) {
        this.props.navigation.navigate(name, {useId: id});
    }
}